<template>
	<om-addpage style="padding-top: 35px;" :busCode="busCode" :menuName="menuName" @formSubmit="formSubmit">
		<om-autoform ref="autoform" :initConfigData="mainConfigData" :initValue="initValue"></om-autoform>
		<view class="cu-bar bg-white" v-show="datashows">
			<view class="action" style="font-size: 16px; margin-left: 0;">
				<text class="title-Icon"><span></span></text>
				<text class="margin-left"><span>公司层指标图表</span></text>
			</view>
		</view>
		<view class="container" v-show="datashows" v-for="(item,index) in dataLists" :key="index">
			<uni-collapse :accordion="true">
				<uni-collapse-item :title="item.indexDictName" show-animation :showIconText="true" :open="true">
					<view class="table-data">
						<ot-table 
							textAlign="left" 
							titleTextAlign="center" 
							:tableData="item.data" 
							:columns="item.tableColumns"
						>
						</ot-table>
					</view>
					<view style="width: 100%;margin-left: 12px;">
						<om-ucharts :chartType="item.pieChart.type" :opts="item.pieChart" :canvasId="'canvas'+item.pieChart.id"></om-ucharts>
					</view>
					<view style="width: 100%;margin-left: 12px;">
						<om-ucharts :chartType="item.lineChart.type" :opts="item.lineChart" :canvasId="'canvas'+item.lineChart.id"></om-ucharts>
					</view>
				</uni-collapse-item>
			</uni-collapse>
		</view>
		<view class="cu-bar bg-white" v-show="datashow">
			<view class="action" style="font-size: 16px; margin-left: 0;">
				<text class="title-Icon"><span></span></text>
				<text class="margin-left"><span>人力资源分析</span></text>
			</view>
		</view>
		<view class="container" v-show="datashow" v-for="(item,index) in dataList" :key="index">
			<uni-collapse :accordion="true">
				<uni-collapse-item :title="item.title" show-animation :showIconText="true" :open="true">
					<view class="table-data">
						<ot-table 
							textAlign="left" 
							titleTextAlign="center" 
							:tableData="item.tableData" 
							:columns="item.tableColumns"
						>
						</ot-table>
					</view>
					<view style="width: 100%;margin-left: 12px;">
						<om-ucharts :chartType="item.pieChart.type" :opts="item.pieChart" :canvasId="'canvas'+item.pieChart.id"></om-ucharts>
					</view>
					<view style="width: 100%;margin-left: 12px;">
						<om-ucharts :chartType="item.lineChart.type" :opts="item.lineChart" :canvasId="'canvas'+item.lineChart.id"></om-ucharts>
					</view>
				</uni-collapse-item>
			</uni-collapse>
		</view>
	</om-addpage>
	
</template>

<script>
	import {
		errorModal,
		ignoreHtml,
		getUrl,
		confirmModal,
		ptFloat,
		minusF
	} from '@/static/js/common.js';
	import {
		changeConfigAttr,
		buildFormData,
		formValidation,
		tranferToEditors,
		changeEditor,
		setSubmitSubValue,
		configSelectData,
		hasValue,
		formShowLoading,
		getFormFields,
		formModelLoad,
		getWorkCacheKey
	} from '@/static/js/formUtil.js';
	import urlUtil from '@/static/js/urlUtil.js';
	import { mapState } from 'pinia';
	import {useLoginUserStore} from '@/stores/login-user.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildFormData({
				moneyCacheKey:"obj-yy-toperationAnalysisReport-money-cache",
				posId:"",
				dataList: [],
				datashow: false,
				dataLists: [],
				datashows: false,
			})
		},
		computed: {
			...mapState(useLoginUserStore, ['userName', 'userId'])
		},
		methods:{
			formSubmit(){
				let _that = this
				_that.om.formSave("toperationAnalysisReport/addToperationAnalysisReport",_that.formdata,_that)
			},
			verifyRank1(){
				let _that = this
				if(!_that.$refs.autoform.formdata.year){
					_that.om.toast("请先选择年度",3000)
					return false
				}else{
					return true
				}
			},
			onSelectMonth(item){
				let _that = this
				if(_that.$refs.autoform.formdata.year&&_that.$refs.autoform.formdata.indexId&&_that.$refs.autoform.formdata.rank2){
					this.initInstData(_that.$refs.autoform.formdata.year,item.code,_that.$refs.autoform.formdata.rank1,_that.$refs.autoform.formdata.rank2)
				}
				_that.getTableChart()
			},
			getMonthList(){
				let _that = this
				_that.om.request(
					"dictZero/getListByCode",
					{
						code:"35803"
					}
				).then(res=>{
					_that.$refs.autoform.changeEditor("title_basic","monthCode","data",configSelectData(res,"code","dicname"))
					_that.$refs.autoform.initSelectIndex("title_basic","monthCode")
				})
			},
			getTableChart(){
				let _that = this
				_that.datashow = true
				_that.om.request(
					"/operationAnalysis/getResponse",{
						year: _that.$refs.autoform.formdata.year,
						month: _that.$refs.autoform.formdata.monthName.substring(0,_that.$refs.autoform.formdata.monthName.length-1)
					}
				).then(res=>{
					for(let i=0; i<res.value.length; i++){
						res.value[i].tableColumns = []
						res.value[i].tableData = []
						res.value[i].pieChart = {
							type: 'pie',
							series: [],
							id: 'pie'+i
						}
						res.value[i].lineChart = {
							type: 'line',
							series: [],
							categories: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
							id: 'line'+i
						}
						let dataNames = [];
						for(let r=0; r<res.value[i].list.length; r++){
							if(r==(res.value[i].list.length-1)){
								let obj = {
									title: res.value[i].list[r].list[0].itemName,
									key: 'itemName',
									width: 300,
								};
								let obj2 = {
									title: res.value[i].list[r].list[0].num,
									key: 'num',
									width: 200,
								};
								let obj3 = {
									title: res.value[i].list[r].list[0].rateName,
									key: 'rateName',
									width: 200,
								};
								res.value[i].tableColumns.push(obj)
								res.value[i].tableColumns.push(obj2)
								res.value[i].tableColumns.push(obj3)
								
								let zjsonArr = res.value[i].list[r].list
								for(var m=0; m<zjsonArr.length; m++){
								    if(zjsonArr[m].itemId){
										let obj = {
											name: zjsonArr[m].itemName,
											data: parseInt(zjsonArr[m].rate)
										}
										res.value[i].pieChart.series.push(obj)
									}
								}
							}
							for(let m=0; m<res.value[i].list[r].list.length; m++){
								if(m>0){
									let obj = {
										itemName: res.value[i].list[r].list[m].itemName,
										num: res.value[i].list[r].list[m].num,
										rateName: res.value[i].list[r].list[m].rateName,
									};
									res.value[i].tableData.push(obj)
								}
								if(res.value[i].list[r].list[m].itemId){
								    dataNames.push(res.value[i].list[r].list[m].itemName)
								}
							}
						}
						let zdataNames = _that.unique(dataNames)
						
						for(let n=0; n<zdataNames.length; n++){
							let obj = {
								name: zdataNames[n],
								data: [null,null,null,null,null,null,null,null,null,null,null,null]
							}
							for(let t=0; t<res.value[i].list.length; t++){
								for(let s=0; s<res.value[i].list[t].list.length; s++){
									if(res.value[i].list[t].list[s].itemName == zdataNames[n]){
										obj.data.splice((res.value[i].list[t].month-1),0,res.value[i].list[t].list[s].rate)
									}
								}
							}
							res.value[i].lineChart.series.push(obj)
						}
					}
					_that.dataList = res.value
				})
			},
			unique(arr) {
			    return Array.from(new Set(arr))
			},
			getMoneyUnitList(){
				let _that = this
				_that.om.request(
					"indexDict/getMoneyUnitIndexList"
				).then(res=>{
					_that.$refs.autoform.changeEditor("title_rankCondition","rank1",{
						link:'../../public/pageSearch/pageSearch',
						"linkParam":{
							other:JSON.stringify({}),
							url:"dictZero/getComboTree",
							namefield:"dicname",
							defaultData:JSON.stringify(res),
							initload:true,
							cachename:_that.moneyCacheKey,
						}
					})
				})
			},
			getRank2List(){
				let _that = this
				_that.om.request(
					"dictZero/getListByCode",
					{
						code:"38365"
					},
					"post"
				).then(res=>{
					_that.$refs.autoform.changeEditor("title_rankCondition","rank2","data",configSelectData(res,"code","dicname"))
					_that.$refs.autoform.initSelectIndex("title_rankCondition","rank2")
				})
			},
			getDataList(){
				let _that = this
				_that.om.request(
					"tmonthlyPlan/findAllIndexEchart",
					{
						posId:_that.posId,
						year:_that.$refs.autoform.formdata.year
					},
					"post"
				).then(res=>{
					let arr = []
					for(let index in res.value){
						let obj = {
							categories:[],
							series:[],
							title:"",
							type:'line'
						}
						obj.categories = res.value[index].xAxis.data
						obj.series = res.value[index].series
						obj.title = res.value[index].title
						obj.name = res.value[index].yAxis.name
						obj.listTitle = ["折线图","柱状图"]
						obj.listValue = ["line","column"]
						arr.push(obj)
					}
					_that.subEditorObj["title_chart"].workList = arr
				})
			},
			initInstData(year,monthCode,indexId,instCode){
				let _that = this
				_that.om.request(
					"toperationAnalysisReport/getInstData",
					{
						year: year,
						monthCode: monthCode,
						indexId: indexId,
						instCode: instCode
					}
				).then(res=>{
					if(res.length){
						_that.subEditorObj["title_inst"].workList = res
						_that.$refs.autoform.changeConfigAttr("title_inst","length",res.length || 0)
						_that.om.toast("加载了"+res.length+"条部门业绩排名信息",3000)
					}else{
						_that.subEditorObj["title_inst"].workList = ""
						_that.om.toast("加载了0条部门业绩排名信息",3000)
					}
					
				})
			},
			onSelectRank2(item){
				let _that = this
				this.initInstData(_that.$refs.autoform.formdata.year,_that.$refs.autoform.formdata.monthCode,_that.$refs.autoform.formdata.rank1,item.code)
			},
			onSelectYear(item){
				let _that = this
				this.getMonthList()
				this.getMoneyUnitList()
				this.getDataList()
				this.getRank2List()
				this.getDataChartList()
				if(_that.$refs.autoform.formdata.monthCode&&_that.$refs.autoform.formdata.rank1&&_that.$refs.autoform.formdata.rank2){
					this.initInstData(item.value,_that.$refs.autoform.formdata.monthCode,_that.$refs.autoform.formdata.rank1,_that.$refs.autoform.formdata.rank2)
				}
			},
			zdataAdd(data,year,nyear) {
			        var arr = [];
			        var isdata = Object.keys(data).length == 0 ? false : true;
			        var obj1 = {},obj2 = {};
			        if(year == nyear){
			            obj1.ztype = '本年月份执行数';
			            obj2.ztype = '本年月份目标值';
			            obj2.zid = isdata ? data.id : '';
			            obj2.zsum = isdata ? data.planSum : '';
			            obj2.zmonth1 = isdata ? data.planSum1 : '';
			            obj2.zmonth2 = isdata ? data.planSum2 : '';
			            obj2.zmonth3 = isdata ? data.planSum3 : '';
			            obj2.zmonth4 = isdata ? data.planSum4 : '';
			            obj2.zmonth5 = isdata ? data.planSum5 : '';
			            obj2.zmonth6 = isdata ? data.planSum6 : '';
			            obj2.zmonth7 = isdata ? data.planSum7 : '';
			            obj2.zmonth8 = isdata ? data.planSum8 : '';
			            obj2.zmonth9 = isdata ? data.planSum9 : '';
			            obj2.zmonth10 = isdata ? data.planSum10 : '';
			            obj2.zmonth11 = isdata ? data.planSum11 : '';
			            obj2.zmonth12 = isdata ? data.planSum12 : '';
			            obj2.zquarterlysum = isdata ? data.sum : '';
			            arr.push(obj2)
			        }else if((year+1) == nyear){
			            obj1.ztype = '上年月份执行数';
			        }else{
			            obj1.ztype = '前年月份执行数';
			        }
			        obj1.zid = isdata ? data.id : '';
			        obj1.zsum = isdata ? data.planSum : '';
			        obj1.zmonth1 = isdata ? data.monthSum1 : '';
			        obj1.zmonth2 = isdata ? data.monthSum2 : '';
			        obj1.zmonth3 = isdata ? data.monthSum3 : '';
			        obj1.zmonth4 = isdata ? data.monthSum4 : '';
			        obj1.zmonth5 = isdata ? data.monthSum5 : '';
			        obj1.zmonth6 = isdata ? data.monthSum6 : '';
			        obj1.zmonth7 = isdata ? data.monthSum7 : '';
			        obj1.zmonth8 = isdata ? data.monthSum8 : '';
			        obj1.zmonth9 = isdata ? data.monthSum9 : '';
			        obj1.zmonth10 = isdata ? data.monthSum10 : '';
			        obj1.zmonth11 = isdata ? data.monthSum11 : '';
			        obj1.zmonth12 = isdata ? data.monthSum12 : '';
			        obj1.zquarterlysum = isdata ? data.sum : '';
			        arr.push(obj1)
			        return arr
			    },
			getDataChartList(){
				let _that = this
				_that.om.request(
					"/statisticalSummaryShow/findDatatListByParam1",
					{
						postIdStr:_that.posId,
						yearStr:(_that.$refs.autoform.formdata.year-2)+','+(_that.$refs.autoform.formdata.year-1)+','+_that.$refs.autoform.formdata.year
					},
					"post"
				).then(res=>{
					if(res.succeed) {
						let _that = this
					    if (res.value.length == 0) {
					        _that.datashows = false
					    } else {
					        _that.datashows = true
													var zarr = [];
													let year = _that.$refs.autoform.formdata.year;
							                        var data = _that._.groupBy(res.value, 'indexDictId');
							                        data = Object.values(data)
							                        for (var i = 0; i < data.length; i++) {
							                            if (data[i].length > 1) {
							                                data[i] = Object.values(_that._.groupBy(data[i], 'indexCategoryName'))
							                                for (var r = 0; r < data[i].length; r++) {
							                                    if (data[i][r].length > 1) {
							                                        data[i][r] = Object.values(_that._.groupBy(data[i][r], 'userId'))
							                                        for (var m = 0; m < data[i][r].length; m++) {
							                                            if (data[i][r][m].length > 1) {
							                                                data[i][r][m] = Object.values(_that._.groupBy(data[i][r][m], 'postId'))
							                                                for (var n = 0; n < data[i][r][m].length; n++) {
							                                                    zarr.push(data[i][r][m][n])
							                                                }
							                                            } else {
							                                                zarr.push(data[i][r][m])
							                                            }
							                                        }
							                                    } else {
							                                        zarr.push(data[i][r])
							                                    }
							                                }
							                            } else {
							                                zarr.push(data[i])
							                            }
							                        }
													var showarr = [];
							                        for (var i = 0; i < zarr.length; i++) {
							                            var obj = {
							                                indexDictId: zarr[i][0].indexDictId,
							                                indexDictName: zarr[i][0].indexDictName,
							                                indexCategoryName: zarr[i][0].indexCategoryName,
							                                userId: zarr[i][0].userId,
							                                userName: zarr[i][0].userName,
							                                postId: zarr[i][0].postId,
							                                postName: zarr[i][0].postName,
							                                data: [{}, {}, {}, {}],
							                                quarterlySum: [],
							                            }
							                            if (zarr[i].length == 1) {
							                                var darr = _that.zdataAdd(zarr[i][0], zarr[i][0].year, year)
							                                if (zarr[i][0].year == year) {
							                                    obj.data.splice(3, 1, darr[0])
							                                    obj.data.splice(2, 1, darr[1])
							                                    var sdarr1 = _that.zdataAdd([], (zarr[i][0].year - 1), year)
							                                    var sdarr2 = _that.zdataAdd([], (zarr[i][0].year - 2), year)
							                                    obj.data.splice(1, 1, sdarr1[0])
							                                    obj.data.splice(0, 1, sdarr2[0])
							                                    var dataArr = [{
							                                        value: zarr[i][0].quarterlySum1,
							                                        name: '一季度执行数',
							                                    }, {
							                                        value: zarr[i][0].quarterlySum2,
							                                        name: '二季度执行数',
							                                    }, {
							                                        value: zarr[i][0].quarterlySum3,
							                                        name: '三季度执行数',
							                                    }, {
							                                        value: zarr[i][0].quarterlySum4,
							                                        name: '四季度执行数',
							                                    }]
							                                    obj.quarterlySum = dataArr;
							                                } else if ((zarr[i][0].year + 1) == year) {
							                                    obj.data.splice(1, 1, darr[0])
							                                    var sdarr1 = _that.zdataAdd([], (zarr[i][0].year + 1), year)
							                                    var sdarr2 = _that.zdataAdd([], (zarr[i][0].year - 1), year)
							                                    obj.data.splice(3, 1, sdarr1[0])
							                                    obj.data.splice(2, 1, sdarr1[1])
							                                    obj.data.splice(0, 1, sdarr2[0])
							                                    var dataArr = [{
							                                        value: 0,
							                                        name: '一季度执行数',
							                                    }, {
							                                        value: 0,
							                                        name: '二季度执行数',
							                                    }, {
							                                        value: 0,
							                                        name: '三季度执行数',
							                                    }, {
							                                        value: 0,
							                                        name: '四季度执行数',
							                                    }]
							                                    obj.quarterlySum = dataArr;
							                                }
							                                else {
							                                    obj.data.splice(0, 1, darr[0])
							                                    var sdarr1 = _that.zdataAdd([], (zarr[i][0].year + 2), year)
							                                    var sdarr2 = _that.zdataAdd([], (zarr[i][0].year + 1), year)
							                                    obj.data.splice(3, 1, sdarr1[0])
							                                    obj.data.splice(2, 1, sdarr1[1])
							                                    obj.data.splice(1, 1, sdarr2[0])
							                                    var dataArr = [{
							                                        value: 0,
							                                        name: '一季度执行数',
							                                    }, {
							                                        value: 0,
							                                        name: '二季度执行数',
							                                    }, {
							                                        value: 0,
							                                        name: '三季度执行数',
							                                    }, {
							                                        value: 0,
							                                        name: '四季度执行数',
							                                    }]
							                                    obj.quarterlySum = dataArr;
							                                }
							                            } else if (zarr[i].length == 2) {
							                                var yeararr = [];
							                                var zyeararr = [(parseInt(year) - 2), (parseInt(year) - 1), parseInt(year)];
							                                for (var r = 0; r < zarr[i].length; r++) {
							                                    yeararr.push(zarr[i][r].year)
							                                    var darr = _that.zdataAdd(zarr[i][r], zarr[i][r].year, year)
							                                    if (zarr[i][r].year == year) {
							                                        obj.data.splice(3, 1, darr[0])
							                                        obj.data.splice(2, 1, darr[1])
							                                        var dataArr = [{
							                                            value: zarr[i][r].quarterlySum1,
							                                            name: '一季度执行数',
							                                        }, {
							                                            value: zarr[i][r].quarterlySum2,
							                                            name: '二季度执行数',
							                                        }, {
							                                            value: zarr[i][r].quarterlySum3,
							                                            name: '三季度执行数',
							                                        }, {
							                                            value: zarr[i][r].quarterlySum4,
							                                            name: '四季度执行数',
							                                        }]
							                                        obj.quarterlySum = dataArr;
							                                    } else if ((zarr[i][r].year + 1) == year) {
							                                        obj.data.splice(1, 1, darr[0])
							                                        var dataArr = [{
							                                            value: 0,
							                                            name: '一季度执行数',
							                                        }, {
							                                            value: 0,
							                                            name: '二季度执行数',
							                                        }, {
							                                            value: 0,
							                                            name: '三季度执行数',
							                                        }, {
							                                            value: 0,
							                                            name: '四季度执行数',
							                                        }]
							                                        obj.quarterlySum = dataArr;
							                                    } else {
							                                        obj.data.splice(0, 1, darr[0])
							                                        var dataArr = [{
							                                            value: 0,
							                                            name: '一季度执行数',
							                                        }, {
							                                            value: 0,
							                                            name: '二季度执行数',
							                                        }, {
							                                            value: 0,
							                                            name: '三季度执行数',
							                                        }, {
							                                            value: 0,
							                                            name: '四季度执行数',
							                                        }]
							                                        obj.quarterlySum = dataArr;
							                                    }
							                                }
							                                var dyear = _.difference(yeararr, zyeararr);
							                                if (dyear == year) {
							                                    var darr = _that.zdataAdd([], dyear.year, year)
							                                    obj.data.splice(3, 1, darr[0])
							                                    obj.data.splice(2, 1, darr[1])
							                                } else if ((dyear + 1) == year) {
							                                    var darr = _that.zdataAdd([], dyear.year, year)
							                                    obj.data.splice(1, 1, darr[0])
							                                } else {
							                                    var darr = _that.zdataAdd([], dyear.year, year)
							                                    obj.data.splice(0, 1, darr[0])
							                                }
							                            } else {
							                                for (var r = 0; r < zarr[i].length; r++) {
							                                    var darr = _that.zdataAdd(zarr[i][r], zarr[i][r].year, year)
							                                    if (zarr[i][r].year == year) {
							                                        obj.data.splice(3, 1, darr[0])
							                                        obj.data.splice(2, 1, darr[1])
							                                        var dataArr = [{
							                                            value: zarr[i][r].quarterlySum1,
							                                            name: '一季度执行数',
							                                        }, {
							                                            value: zarr[i][r].quarterlySum2,
							                                            name: '二季度执行数',
							                                        }, {
							                                            value: zarr[i][r].quarterlySum3,
							                                            name: '三季度执行数',
							                                        }, {
							                                            value: zarr[i][r].quarterlySum4,
							                                            name: '四季度执行数',
							                                        }]
							                                        obj.quarterlySum = dataArr;
							                                    } else if ((zarr[i][r].year + 1) == year) {
							                                        obj.data.splice(1, 1, darr[0])
							                                    } else {
							                                        obj.data.splice(0, 1, darr[0])
							                                    }
							                                }
							                            }
							                            showarr.push(obj)
							                        }	
													
													for(let i=0; i<showarr.length; i++){
														showarr[i].tableColumns = [{
															title: '',
															key: 'ztype',
															width: 160,
														},{
															title: '年度目标值',
															key: 'zsum',
															width: 130,
														},{
															title: '年度执行数',
															key: 'zquarterlysum',
															width: 130,
														},{
															title: '1月',
															key: 'zmonth1',
															width: 80,
														},{
															title: '2月',
															key: 'zmonth2',
															width: 80,
														},{
															title: '3月',
															key: 'zmonth3',
															width: 80,
														},{
															title: '4月',
															key: 'zmonth4',
															width: 80,
														},{
															title: '5月',
															key: 'zmonth5',
															width: 80,
														},{
															title: '6月',
															key: 'zmonth6',
															width: 80,
														},{
															title: '7月',
															key: 'zmonth7',
															width: 60,
														},{
															title: '8月',
															key: 'zmonth8',
															width: 80,
														},{
															title: '9月',
															key: 'zmonth9',
															width: 80,
														},{
															title: '10月',
															key: 'zmonth10',
															width: 80,
														},{
															title: '11月',
															key: 'zmonth11',
															width: 80,
														},{
															title: '12月',
															key: 'zmonth12',
															width: 80,
														}]
														showarr[i].pieChart = {
															type: 'pie',
															series: [],
															id: 'zpie'+i
														}
														showarr[i].lineChart = {
															type: 'line',
															series: [],
															categories: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
															id: 'zline'+i
														}
														
														for(let r=0; r<showarr[i].quarterlySum.length;r++){
															let obj = {
																name: showarr[i].quarterlySum[r].name,
																data: showarr[i].quarterlySum[r].value
															}
															showarr[i].pieChart.series.push(obj)
														}
														
														for(let r=0; r<showarr[i].data.length;r++){
															let obj = {
																name: showarr[i].data[r].ztype,
																data: [showarr[i].data[r].zmonth1 ? showarr[i].data[r].zmonth1 : null,
																showarr[i].data[r].zmonth2 ? showarr[i].data[r].zmonth2 : null,
																showarr[i].data[r].zmonth3 ? showarr[i].data[r].zmonth3 : null,
																showarr[i].data[r].zmonth4 ? showarr[i].data[r].zmonth4 : null,
																showarr[i].data[r].zmonth5 ? showarr[i].data[r].zmonth5 : null,
																showarr[i].data[r].zmonth6 ? showarr[i].data[r].zmonth6 : null,
																showarr[i].data[r].zmonth7 ? showarr[i].data[r].zmonth7 : null,
																showarr[i].data[r].zmonth8 ? showarr[i].data[r].zmonth8 : null,
																showarr[i].data[r].zmonth9 ? showarr[i].data[r].zmonth9 : null,
																showarr[i].data[r].zmonth10 ? showarr[i].data[r].zmonth10 : null,
																showarr[i].data[r].zmonth11 ? showarr[i].data[r].zmonth11 : null,
																showarr[i].data[r].zmonth12 ? showarr[i].data[r].zmonth12 : null,]
															}
															showarr[i].lineChart.series.push(obj)
														}
													}
													_that.dataLists = showarr;									
						}
					}
				})
			},
			initLoad(options){
				let _that = this
				let ajaxArr = [
					urlUtil.zposUrl(options.code),
					{
						url:"toperationAnalysisReport/getCeoInfo",
						method:"post"
					}
				]
				let fileId = options.fileId
				if(fileId){
					ajaxArr.push({
						url:'toperationAnalysisReport/getInfo',
						param:{
							id:fileId
						},
						method:"post"
					})
				}
				formModelLoad(ajaxArr,function(res,mainData){
					mainData = mainData.splice(2,1); 
					changeEditor("topinfo","zposId","data",configSelectData(res[0],"id","posname"),mainData)
					let date = new Date()
					let yearList = [
						{
							name:Number(date.getFullYear())-1,
							value:Number(date.getFullYear())-1
						},{
							name:Number(date.getFullYear()),
							value:Number(date.getFullYear())
						}
					]
					changeEditor("title_basic","year","data",configSelectData(yearList,"name","value"),mainData)
					changeEditor("title_basic","userName",{
						defaultName:res[1].value.userName
					},null,mainData)
					_that.posId = res[1].value.posId
					changeConfigAttr("title_inst","showLength",true,mainData)
					if(_that.subEditorObj["title_inst"]){
						changeEditor("title_inst","instStr",{
							showAdd:false,
							showDel:false,
							showLength:true,
							length:0,
							titleTemplate:"排名:<%=rank%>",
							subtitle1Template:"部门负责人:<%=userName%>|部门名称:<%=instName%>",
							subtitle2Template:"上级部门名称:<%=parentInstName%>|指标执行数:<%=indexNum%>",
							subtitle3Template:"月度排名汇总(次数):<%=rankInfo%>"
						},null,mainData)
					}
					if(_that.subEditorObj["title_audit"]){
						changeEditor("title_audit","auditStr",{
							titleTemplate:"<%=instName%>",
							subtitle1Template:"<%=instUserName%>"
						},null,mainData)
					}
					if(fileId){
						let fieldArr = getFormFields(mainData)
						fieldArr.push("id")
						for(let index in res[2].value.toperationAnalysisReport){
							if(fieldArr.includes(index)){
								_that.$refs.autoform.$set(_that.$refs.autoform.formdata,index,res[2].value.toperationAnalysisReport[index])
								_that.$set(_that.formdata,index,res[2].value.toperationAnalysisReport[index])
							}
						}
						let auditList = _that._.cloneDeep(res[2].value.auditList)
						_that.subEditorObj["title_audit"].workList = auditList
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"auditStr",JSON.stringify(auditList))
						_that.$set(_that.formdata,"auditStr",JSON.stringify(auditList))
						let instList1 = _that._.cloneDeep(res[2].value.instList1)
						_that.subEditorObj["title_inst"].workList = instList1
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"instStr",JSON.stringify(instList1))
						_that.$set(_that.formdata,"instStr",JSON.stringify(instList1))
						changeConfigAttr("title_inst","length",instList1.length || 0,mainData)
						_that.$nextTick(function(){
							_that.$refs.autoform.initSelectIndex("title_basic","year")
							_that.getMonthList()
							_that.getDataList()
							_that.getRank2List()
						})
					}
				},options)
			}
		},
		onLoad(options) {
			let _that = this
			_that.initLoad(options)
		},
		onUnload(){
					//#ifdef APP-PLUS
					let _that = this;
					if (_that.$refs.autoform) {
						for (var fieldId in _that.subEditorObj) {
							uni.removeStorage({
								key: getWorkCacheKey(fieldId)
							});
						}
					}
					//#endif
				},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				for(let fieldId in _that.subEditorObj){
					let editor = _that.subEditorObj[fieldId]
					uni.getStorage({
						key: getWorkCacheKey(fieldId),
						success: function(res) {
							editor.workList = res.data;
							uni.removeStorage({
								key: getWorkCacheKey(fieldId)
							});
						}
					});
				}
				uni.getStorage({
					key:_that.moneyCacheKey,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.rank1Name = d.dicname
							formdata.rank1 = d.id
							if(formdata.year&&formdata.monthCode&&formdata.rank2){
								this.initInstData(formdata.year,formdata.monthCode,d.id,formdata.rank2)
							}
							uni.removeStorage({
								key:_that.moneyCacheKey
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.title-Icon{
	    width: 6px;
	    height: 18px;
	    border-radius: 3px;
	    margin-left: 3px;
	    background-color: #39B54A;
	}
	.container{
		.tit{
			margin-left: 12px;
			margin-top: 10px;
			color: #007aff;
		}
	}
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
